package com.ziroom.finance.rabbitmq.common.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 公司名称
 * @Author liyb58
 * @Date 2016/12/12 15:24
 * @return
 */
public enum CompanyNameEnums {

    //110000 北京链家  310000 上海自如  440300  深圳自如  801000  北京自如 111111 自如科技

    BJ_ZIROOM("5005",12L,"HL011","北京自如"),
    SZ_ZIROOM("8002",24L,"HL025","深圳自如"),
    SH_ZIROOM("5010",50L,"HL018","上海自如"),
    ZIROOM_LIFE("8010",13L,"HL011","自如生活"),
    ZIROOM_HOMESTAY("8013",19L,"HL011","自如民宿");

    private String companyCode;
    private Long cityCode;
    private String companyName;
    private String ehrCode;

    CompanyNameEnums(String companyCode, Long cityCode,String ehrCode, String companyName) {
        this.ehrCode = ehrCode;
        this.companyCode = companyCode;
        this.cityCode = cityCode;
        this.companyName = companyName;
    }

    public String getEhrCode() {
        return ehrCode;
    }

    public void setEhrCode(String ehrCode) {
        this.ehrCode = ehrCode;
    }

    public String getCompanyCode() {
        return companyCode;
    }

    public void setCompanyCode(String companyCode) {
        this.companyCode = companyCode;
    }

    public Long getCityCode() {
        return cityCode;
    }

    public void setCityCode(Long cityCode) {
        this.cityCode = cityCode;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    /**
     * 根据newcode 获取城市名称
     * @param cityCode
     * @return
     */
    public static String getCompanyCodeByCityCode(Long cityCode) {
        for (CompanyNameEnums c : CompanyNameEnums.values()) {
            if (c.cityCode == cityCode) {
                return c.getCompanyCode();
            }
        }
        return "";
    }

    /**
     * 根据companyCode 获取ehr城市编码
     * @param companyCode
     * @return
     */
    public static String getCompanyCodeByEhrCode(String companyCode) {
        for (CompanyNameEnums c : CompanyNameEnums.values()) {
            if (c.getCompanyCode().equals(companyCode)) {
                return c.getEhrCode();
            }
        }
        return "";
    }


    /**
     * 根据newcode 获取城市名称
     * @param companyCode
     * @return
     */
    public static String getCompanyCodeByCompanyCode(String companyCode) {
        for (CompanyNameEnums c : CompanyNameEnums.values()) {
            if (c.getCompanyCode().equals(companyCode)) {
                return c.getCompanyName();
            }
        }
        return "";
    }


    /**
     * lookup 中存储的是该类型的代码以及代码对应的枚举类
     * @return
     */
    public static Map<String, CompanyNameEnums> lookup() {
        LinkedHashMap<String, CompanyNameEnums> result = new LinkedHashMap<>();
        for (CompanyNameEnums c : CompanyNameEnums.values()) {
            result.put(c.getCompanyCode(), c);
        }
        return result;
    }

}
